/*
	Copyright (C) 2009 Salil Bhagurkar
	
	This file is part of ViSE
	
	ViSE is free software: you can redistribute it and/or modify
	it under the terms of the GNU Lesser General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.
	
	ViSE is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU Lesser General Public License for more details.
	
	You should have received a copy of the GNU Lesser General Public License
	along with ViSE.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef _MEMIO_H_
#define _MEMIO_H_

#include <arch/types.h>
#include <string.h>

typedef unsigned long io_t;


static inline void writeb(io_t addr,u8 val) {
	*(u8 *)addr = val;
}

static inline void writew(io_t addr,u16 val) {
	*(u16 *)addr = val;
}

static inline void writel(io_t addr,u32 val) {
	*(u32 *)addr = val;
}

static inline u8 readb(io_t addr) {
	return *(u8 *)addr;
}

static inline u8 readw(io_t addr) {
	return *(u16 *)addr;
}

static inline u8 readl(io_t addr) {
	return *(u32 *)addr;
}

static inline void io_memset(io_t addr,int val,size_t count) {
	memset((void *)addr,val,count);
}

static inline void io_memcpy(io_t addr,io_t srcaddr,size_t count) {
	memcpy((void *)addr,(void *)srcaddr,count);
}

static inline void io_memmove(io_t addr,io_t srcaddr,size_t count) {
	memmove((void *)addr,(void *)srcaddr,count);
}

#endif
